# -- coding: utf-8 --
# file: str_operate.py
#


def inputIsOK(str):
    """
    判断str是否1~49之间的数字

    Args:
        str ([字符串]): [description]

    Returns:
        [布尔值]: [description]
    """

    return True if str.isnumeric() and int(str) > 0 and int(str) < 50 else False


def arrIsOK(arr):
    """判断字符串数组是否正确

    Args:
        arr ([列表]): [description]

    Returns:
        [布尔值]: [description]
    """
    for item in arr:
        if item == '':
            continue
        if not inputIsOK(item):
            return False
    return True


def splitString(aString, splits):
    """把aString按splits分隔符切片

    Args:
        aString ([字符串]): [description]
        splits ([字符串]): [description]

    Returns:
        [字符串列表]: [description]
    """
    import re
    strings = re.split(splits, aString)
    return strings


def time(Strings, cmpString):
    """在字符串列表Strings中找出cmpString出现的次数

    Args:
        Strings ([字符串列表]): [description]
        cmpString ([字符串]): [description]

    Returns:
        [整数]: [description]
    """
    time = 0
    for s in Strings:
        if s == cmpString:
            time += 1
    return time
